package com.ponhu.ea2.stockcenter.provider.service.entity.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ponhu.ea2.stockcenter.provider.constants.CommonConstant;
import com.ponhu.ea2.stockcenter.provider.entity.StockChangeMqLogs;
import com.ponhu.ea2.stockcenter.provider.mapper.StockChangeMqLogsMapper;
import com.ponhu.ea2.stockcenter.provider.service.entity.StockChangeMqLogsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StockChangeMqLogsServiceImpl
        extends ServiceImpl<StockChangeMqLogsMapper, StockChangeMqLogs>
        implements StockChangeMqLogsService {

    @Override
    public Boolean updStatusByInventoryCodes(List<String> inventoryCodes, Integer status) {

        LambdaUpdateWrapper<StockChangeMqLogs> updateWrapper = Wrappers
                .lambdaUpdate(StockChangeMqLogs.class)
                .set(StockChangeMqLogs::getStatus, status)
                .in(StockChangeMqLogs::getInventoryCode, inventoryCodes);

        return update(updateWrapper);
    }

    @Override
    public List<StockChangeMqLogs> getListByStatus(Integer status) {

        LambdaQueryWrapper<StockChangeMqLogs> queryWrapper = Wrappers
                .lambdaQuery(StockChangeMqLogs.class)
                .eq(StockChangeMqLogs::getStatus, status);

        return list(queryWrapper);
    }

}
